package com.xxx.blog.controller;

import com.xxx.base.utils.R;
import com.xxx.blog.domain.Article;
import com.xxx.blog.domain.Param;
import com.xxx.blog.service.IParamService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/param")
@Api(tags = "系统参数接口类")
public class ParamController {
    @Autowired private IParamService paramService;

    @GetMapping("/getAllParam")
    @ApiOperation(value = "查询所有")
    public R<Map<String,String>> getParam() {
        List<Param> all = paramService.findAll();
        //普通写法
        HashMap<String, String> map = new HashMap<>();
        all.forEach(param ->
            map.put(param.getParamKey(), param.getParamValue())
        );
        //Stream流写法(常用!!!!!!)
        return R.ok(map);
    }

}
